package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.dto.BedDto;
import com.zzyl.entity.Bed;
import com.zzyl.mapper.BedMapper;
import com.zzyl.service.BedService;
import com.zzyl.vo.BedVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BedServiceImpl implements BedService {

    @Autowired
    private BedMapper bedMapper;

    @Override
    public List<BedVo> getBedsByRoomId(Long roomId) {
        return bedMapper.getBedsByRoomId(roomId);
    }

    /**
     * 新增
     *
     * @param dto
     */
    @Override
    public void add(BedDto dto) {
        Bed bed = BeanUtil.toBean(dto, Bed.class);

        bedMapper.insert(bed);
    }

    @Override
    public Bed getBedById(Long id) {
        return bedMapper.getBedById(id);
    }
}

